﻿<!DOCTYPE html>
<html>
<head>
    <script src="/js/header.js"></script>
    <link href="/lib/jquery/jquery-ui.min.css" rel="stylesheet" />
    <script src="/lib/jquery/jquery-ui.min.js"></script>
</head>
<body>
    <div class="data-wrap case" id="container">
        <div class="data-tool clearfix">
            <div class="pull-left form-inline ">
                <a class="btn btn-default btn-sm" data-modal="/view/account/add.html" data-title="新增" data-width="500" data-height="480"><span class="glyphicon glyphicon-plus"></span> 新增</a>
            </div>
            <div class="pull-right">
                <form class="form-inline" id="formSearch">

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">公司名称：</label>
                        <input class="form-control" name="uCompanyName" type="text" />
                    </div>

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">登陆名称：</label>
                        <input class="form-control" name="uLoginName" type="text" />
                    </div>

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">联络电话：</label>
                        <input class="form-control" name="uTelephone" type="text" />
                    </div>

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">状态：</label>
                        <select class="form-control" name="uStatus">
                            <option value="-1">请选择</option>
                            <option value="1">启用</option>
                            <option value="2">禁用</option>
                        </select>
                    </div>
                    <button type="button" class="btn btn-default btn-sm active" id="btnSearch"><span class="glyphicon glyphicon-search"></span> 搜索</button>
                </form>
            </div>
        </div>
        <div class="paging">
        </div>

    </div>
    <script type="text/x-dot-template" id="templatePager">
        <div class="data-body data-scroll">
            <div class="data-view">
                <div class="data-div-view table-responsive">
                    <table class="table table-hover table-striped table-bordered">
                        <thead>
                            <tr>
                                <th class="t_l wd200">登陆名称</th>
                                <th class="t_l wd200">公司名称</th>
                                <th class="t_l">说明</th>
                                <th class="t_l wd150">联络电话</th>
                                <th class="t_l wd150">联络Email</th>
                                <th class="wd50">状态</th>
                                <th class="wd100">谷歌验证</th>

                                <th width="380">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {{~it.tData :item:index}}
                            <tr>
                                <td class="t_l wd200">{{?  item.uLoginName!=null}}{{= item.uLoginName }}{{??}}{{?}}</td>
                                <td class="t_l wd200">{{= item.uCompany.companyName }}</td>
                                <td class="t_l">{{= FlashPay.Util.GetShortStr(item.uDescription) }}</td>
                                <td class="t_l wd150">{{?  item.uTelephone!=null}}{{= item.uTelephone }}{{??}}{{?}}</td>
                                <td class="t_l wd150" title="{{?  item.uEmail!=null}}{{= item.uEmail }}{{??}}{{?}}">{{?  item.uEmail!=null}}{{= item.uEmail }}{{??}}{{?}}</td>
                                <td class="wd50">{{= FlashPay.Util.GetStatusValue(item.uStatus) }}</td>
                                <td class="wd100">{{= FlashPay.Util.GetStatusValue(item.uLoggedIn) }}</td>

                                <td width="380">
                                    {{? item.uId!=item.uUiconfig}}
                                        {{? item.uStatus==1 }}
                                        <a class="btn btn-warning btn-xs" data-confirm='"{{= item.uLoginName }}" <br>确定要<span style="color:#e38d13;">禁用</span>该账号吗？' data-href="/User/ChangeStatus?Id={{= item.uId}}&uStatus=2">禁用</a>
                                        {{?? }}
                                        <a class="btn btn-success btn-xs" data-confirm='"{{= item.uLoginName }}" <br>确定要<span style="color:#419641;">启用</span>该账号吗？' data-href="/User/ChangeStatus?Id={{= item.uId}}&uStatus=1">启用</a>
                                        {{? }}
                                    {{? }}

                                    {{? item.uLoggedIn==1}}
                                    <a class="btn btn-warning btn-xs" data-confirm='"{{= item.uLoginName }}" <br>确定要<span style="color:#e38d13;">禁用</span>谷歌验证吗？' data-href="/User/ChangeLoggedIn?uId={{= item.uId}}&uLoggedIn=2">禁用谷歌验证</a>
                                    {{??}}
                                    <a class="btn btn-success btn-xs" data-confirm='"{{= item.uLoginName }}" <br>确定要<span style="color:#419641;">启用</span>谷歌验证吗？' data-href="/User/ChangeLoggedIn?uId={{= item.uId}}&uLoggedIn=1">启用谷歌验证</a>
                                    {{? }}

                                    {{? item.uStatus!=3 }}
                                    <button type="button" class="btn btn-default btn-xs" data-modal="/view/account/edit.html?id={{= item.uId}}" data-title="编辑 - {{= item.uLoginName }}" data-width="500" data-height="480">
                                        <span class="glyphicon glyphicon-edit"></span> 编辑
                                    </button>
                                    {{? }}

                                    {{? item.uStatus!=3 && (it.statusCode=="1" || item.uId==item.uUiconfig) }}
                                    <button type="button" class="btn btn-primary btn-xs" data-modal="/view/account/resetpassword.html?uid={{= item.uId}}" data-title="重设密码 - {{= item.uLoginName }}" data-width="400" data-height="180">
                                        <span class="glyphicon glyphicon-erase"></span> 重设密码
                                    </button>
                                    {{? }}

                                    {{? item.uStatus!=3 && item.uId!=item.uUiconfig}}
                                    <a class="btn btn-danger btn-xs" data-id="{{= item.uId}}" data-confirm='"{{= item.uLoginName }}" <br>确定要<span style="color:red;">删除</span>该账号吗？' data-href="/User/Delete?Id={{= item.uId}}"><span class="glyphicon glyphicon-trash"></span>&nbsp;刪除</a>
                                    {{? }}
                                </td>
                            </tr>
                            {{~}}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- 必要的分页参数设置 -->
        <input type="hidden" id="TotalCount" value="{{=it.totalCount}}" />
    </script>
    <script type="text/javascript">
        $(function () {
            FlashPay.UI.DataAutoHeight();
            FlashPay.UI.DoSearch();

            $("#btnSearch").click(function () {
                window.currentPage = null;
                doSearch();
            });
        });

        $(document).keyup(function (event) {
            var keycode = event.which;
            if (keycode == 13) {
                FlashPay.UI.DoSearch();
            }
        });

        $("input[name='uLoginName']").autocomplete({
            minLength: 1,
            source: function (request, response) {
                FlashPay.Util.Ajax({
                    url: '/User/GetList',
                    type: 'Get',
                    data: { uLoginName: $("input[name='uLoginName']").val() },
                    success: function (res) {
                        if (res.success) {
                            if (res.tData != null && res.tData.length > 0) {
                                response($.map(res.tData, function (item) {
                                    return {
                                        label: item.uLoginName,
                                        value: item.uLoginName,
                                        id: item.uId
                                    }
                                }))
                            }
                        }
                    }
                });
            }
        });

        $("input[name='uCompanyName']").autocomplete({
            minLength: 1,
            source: function (request, response) {
                FlashPay.Util.Ajax({
                    url: '/Role/CompanySearch',
                    type: 'POST',
                    data: { companyName: $("input[name='uCompanyName']").val() },
                    success: function (res) {
                        if (res.success) {
                            if (res.data != null && res.data.length > 0) {
                                response($.map(res.data, function (item) {
                                    return {
                                        label: item.companyName,
                                        value: item.companyName,
                                        id: item.companyID
                                    }
                                }))
                            }
                        } else {
                            FlashPay.UI.Tip_warning("操作失败！" + res.errorMessage);
                        }
                    },
                    error: function (json) {
                        FlashPay.UI.Tip_warning("操作失败！请查看网络，请重试。");
                    }
                });
            }
        });

        function doSearch() {
            FlashPay.UI.Pager(".paging", { templateId: "templatePager", pageSize: 15, ajax: { url: '/User/GetList' } });
        }

        function Tip_success(word) {
            FlashPay.UI.Tip_success(word);
        }
    </script>
</body>
</html>